package huoye.shops.huoye.operation.presenter;

import com.codeideology.android.utils.StringUtils;

import huoye.shops.base.BasePresenter;
import huoye.shops.base.MineBaseJsonRequestCallback;
import huoye.shops.huoye.operation.model.GuestsDetailData;
import huoye.shops.huoye.operation.model.VipGustsData;
import huoye.shops.huoye.operation.networt.OperationService;
import huoye.shops.huoye.operation.view.IGuestsSetView;
import huoye.shops.huoye.operation.view.INewAddGuestsView;


/**
 * Created by uesr on 2017/7/19.
 */

public class NewAddGuestsPresenter extends BasePresenter<INewAddGuestsView> {

    OperationService mService;



    //通过手机号查找单个用户
    public void searchUser(String mobile){
        //  view.showProcessingIndicator();
        mService.searchUser(mobile,new MineBaseJsonRequestCallback<VipGustsData>(VipGustsData.class) {

            @Override
            public void onSuccess(VipGustsData vipGustsData) {
                super.onSuccess(vipGustsData);
             /*   if(!StringUtils.isNotEmpty(vipGustsData.getNickName())){
                    view.makeToast("未搜索到该嘉宾");
                    return;
                }*/
                view.seekGuests(vipGustsData);
            }

            //网络请求失败
            @Override
            public void onFailure(String msg, String code, Throwable e) {
                super.onFailure(msg, code, e);
                view.makeToast(msg);
            }

            //加载结束
            @Override
            public void onNetworkFail() {
                super.onNetworkFail();
                view.onNetworkFail();
            }

            //加载中
            @Override
            public void onFinish() {
                super.onFinish();
                view.hideProcessingIndicator();
            }
        });
    }



    @Override
    public void onStart() {
        mService = new OperationService();
    }
}
